Skip to content

fix: make the tsd type tests actually run - #322

Open
cryptodev-2s wants to merge 1 commit into
migrate/pr2g-ethereumjsfrom
migrate/pr2h-fix-tsd
Open

fix: make the tsd type tests actually run#322
cryptodev-2s wants to merge 1 commit into
migrate/pr2g-ethereumjsfrom
migrate/pr2h-fix-tsd

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Top of stack #315, on #321.

yarn test:types runs bare tsd, which finds no test files at all. It produces no output and exits 0 regardless, so the 460 lines of type assertions across src/*.test-d.ts have not been checking anything.

Proof, before this change:

$ printf 'expectAssignable<Hex>(999);' >> src/hex.test-d.ts
$ yarn test:types
$ echo $?
0

Pointing tsd at the files explicitly reports it properly and exits 1:

✖  Argument of type 999 is not assignable to parameter of type `0x${string}`.

Cause

tsd resolves test files relative to the types field, which has pointed at ./dist/index.d.cts since ts-bridge was adopted in #182 (2024-04-23). tsd 0.29 does not resolve .d.cts, and the tsd.directory setting does not compensate. 26 releases have shipped since, all with this check silently passing.

Fix

- "test:types": "tsd"
+ "test:types": "tsd --files 'src/*.test-d.ts'"

Fixing the invocation rather than the types field, since the field is correct for consumers and only tsd is confused by it.

All four files pass once actually executed, so none of them needed changing. yarn test:types now exits 1 on a bad assertion and 0 when clean.

Relevance to the migration

This was found while working out what to do with tsd in Phase B, since core has no way to run it. Worth knowing the honest baseline before deciding: these assertions have been dormant for 17 months, so whatever we do with them in core, we are not losing coverage we currently have.


Note

Low Risk
Only changes how the dev test:types script invokes tsd; no runtime or published API changes.

Overview
Fixes a silent no-op in type testing: yarn test:types previously invoked bare tsd, which discovered zero test files (because tsd resolves tests relative to types./dist/index.d.cts, and tsd 0.29 does not handle .d.cts). The command exited 0 without running the assertions in src/*.test-d.ts.

The script now runs tsd --files 'src/*.test-d.ts' so those definition tests actually execute and fail CI when an assertion is wrong, without changing the published types field.

Reviewed by Cursor Bugbot for commit e0aa73c. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s removed this pull request from stack #329 September 9, 2026 11:46
@cryptodev-2s
cryptodev-2s added this pull request to stack #331 September 9, 2026 11:47
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2h-fix-tsd branch 2 times, most recently from 1342ebd to ebe3626 Compare September 9, 2026 16:32
Mrtenz
Mrtenz previously approved these changes Sep 10, 2026
@cryptodev-2s
cryptodev-2s dismissed Mrtenz’s stale review September 10, 2026 10:15

The merge-base changed after approval.

`yarn test:types` runs bare `tsd`, which finds no test files at all. It
produces no output and exits 0 no matter what, so the 460 lines of type
assertions in src/*.test-d.ts have not been checking anything.

Proof: appending `expectAssignable<Hex>(999)` to hex.test-d.ts still exits
0. Pointing tsd at the files explicitly reports it correctly and exits 1.

The cause is the `types` field. tsd resolves test files relative to it, and
it has pointed at ./dist/index.d.cts since ts-bridge was adopted in #182 on
2024-04-23, which tsd 0.29 does not resolve. The `tsd.directory` setting
does not compensate. There have been 26 releases since, all with this check
silently passing.

Fixing the invocation rather than the `types` field, since the latter is
correct for consumers and only tsd is confused by it. All four existing
files pass once actually executed, so nothing needed changing in them.
@cryptodev-2s
cryptodev-2s removed this pull request from stack #331 September 10, 2026 10:40
@cryptodev-2s
cryptodev-2s added this pull request to stack #335 September 10, 2026 10:41
@cryptodev-2s
cryptodev-2s requested a review from Mrtenz September 10, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants